﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class Default3 : System.Web.UI.Page
{
    string strCon = System.Configuration.ConfigurationManager.ConnectionStrings["xxnewsConnectionString"].ConnectionString;
    SqlConnection sqlcon;
    SqlCommand sqlcom;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["pn"] == "" || Session["pn"] == null)
        {
            Response.Redirect("default.aspx");
        }
        if (Session["pngeren"] == "" || Session["pngeren"] == null)
        {
            Response.Redirect("default.aspx");
        }
        if (Session["pn"].ToString().Contains("材料科") == false)
        {
            Response.Redirect("default.aspx?lb=受理");
        }
        if (!IsPostBack)
        {
            for (int i = Convert.ToInt32(DateTime.Now.Year); i >= 2011; i--)
            {
                nian.Items.Add(i.ToString());
            }
            for (int i = 1; i <= 12; i++)
            {
                yue.Items.Add(i.ToString());
            }
            nian.SelectedValue = DateTime.Now.Year.ToString();
            yue.SelectedValue = DateTime.Now.Month.ToString();
        }

    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#D1DDF1'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
        }
        if (e.Row.RowIndex != -1)
        {
            int id = e.Row.RowIndex + 1;
            e.Row.Cells[1].Text = id.ToString();
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string sqlstr = @"SELECT     c_id, lei, chejian, banzu, nian, yue, addname, addtime, addip, chejianname, chejiantime, chejianip, duanname, duantime, duanip, cailiaoname, 
                      cailiaotime, cailiaoip, lingdaoname, lingdaotime, lingdaoip, zt, liezhi
FROM         cailiaoguanli
WHERE   1=1 ";
        if (DropDownList_lei.SelectedValue != "请选择")
        {
            sqlstr += " AND (lei = '" + DropDownList_lei.SelectedValue + "')";
        }
        if (nian.SelectedValue != "请选择")
        {
            sqlstr += " AND (nian = '" + nian.SelectedValue + "')";
        }
        if (yue.SelectedValue != "请选择")
        {
            sqlstr += " AND (yue = '" + yue.SelectedValue + "')";
        }
        if (DropDownList_sscj.SelectedValue != "请选择")
        {
            sqlstr += " AND (chejian = '" + DropDownList_sscj.SelectedValue + "')";
        }
        if (DropDownList_zrbz.SelectedValue != "请选择")
        {
            sqlstr += " AND (banzu = '" + DropDownList_zrbz.SelectedValue + "')";
        }
        sqlstr += " AND (zt =4)  ORDER BY lei,[duantime] desc";
        SqlDataSource1.SelectCommand = sqlstr;
        GridView1.DataBind();

    }
    protected void DropDownList_sscj_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList_zrbz.Items.Clear();
        DropDownList_zrbz.Items.Add(new ListItem("请选择"));
        DropDownList_zrbz.DataBind();
    }
}